home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Applications / mint / mint095 / mint.doc < prev    next >
Text File  |  1993-09-21  |  31KB  |  645 lines

  1. MiNT is Not TOS: A Multitasking Operating System Extension for the Atari ST
  2.  
  3. Copyright 1990,1991,1992 Eric R. Smith. All rights reserved. See the file
  4. "copying" for conditions of redistribution.
  5.  
  6. WARNING: This program does some very low level things to your computer.
  7. MiNT works well on my machine, and I trust my data to it. But
  8. then, I make regular backups, so even if a horrible bug in MiNT that
  9. I haven't found yet trashes my hard drive, I won't lose much. You'll
  10. have to decide for yourself about trusting your data to MiNT. I would
  11. certainly recommend regular backups in any event.
  12.  
  13. MiNT COMES WITH ABSOLUTELY NO WARRANTY, NOR WILL I BE LIABLE FOR ANY
  14. DAMAGES INCURRED FROM THE USE OF IT. USE ENTIRELY AT YOUR OWN RISK!!!
  15.  
  16. Introduction
  17.  
  18. MiNT is an extension of (and eventually, I hope, a replacement for) TOS.
  19. It provides extra services such as multitasking and pipes. If you don't
  20. know what those terms mean, MiNT is probably not for you -- at this stage,
  21. MiNT is still very incomplete and should be regarded as "experimental".
  22.  
  23. MiNT will run a great number of ("most", I hope) TOS programs, including
  24. GEM. As the name says, though, MiNT is not TOS, so it can't be expected to
  25. run all TOS programs, or even all well-behaved TOS programs (although I hope
  26. that it will run "almost all" of the latter!). There are two classes of
  27. incompatibilities with TOS: bugs and features. Bugs are undoubtedly
  28. present; if you find any please report them to me. There are also some
  29. features of MiNT that may cause incompatibilites. Most of these are listed
  30. in the accompanying "features" file. 
  31.  
  32. MiNT tries to emulate TOS 1.4 very closely. If you have TOS 1.0 or 1.2,
  33. you may think you can use MiNT instead of buying TOS 1.4. This isn't really
  34. a very good idea, because MiNT calls TOS, and so having the newer version
  35. of TOS will really speed things up. Besides, the GEM that comes with TOS 1.4
  36. is a lot better than the old GEM.
  37.  
  38.  
  39. Using MiNT
  40.  
  41. MiNT can be started from an AUTO folder, by setting it as a BOOT program
  42. on the desktop (TOS 1.4 or higher only) or by running it. I prefer the AUTO
  43. folder way myself.
  44.  
  45. If you put it in an AUTO folder, it should be the last thing in the folder
  46. (since any later programs in the folder will run only after MiNT is finished,
  47. and MiNT should never finish). MiNT will try to run a program called
  48. "init.prg" in the current directory  (which is the root directory if MiNT
  49. was started from an AUTO folder). If this program isn't found, MiNT will
  50. boot up GEM. You can change the name of the initial program to run
  51. via the "mint.cnf" file (see below).
  52.  
  53. Once MiNT is running, the computer should behave just as it does under TOS,
  54. except that some new drives (U, Q, V, and X) will be available, background
  55. processes can be started, and programs can use the new features of MiNT.
  56.  
  57. MiNT can be asked to provide a trace of the currently executing programs.
  58. Hitting CTRL-ALT-F1 increases the debugging level; hitting CTRL-ALT-F2
  59. decreases it, and hitting CTRL-ALT-F3 changes where the debugging output
  60. goes; pressing it once changes it from the screen to the printer, pressing
  61. it again changes it to the RS232 port, pressing a third time sends debugging
  62. output to the MIDI port. Pressing CTRL-ALT-F4 resets output to the screen.
  63. This feature was designed to aid in debugging MiNT itself, but can also be
  64. useful in finding problems with user programs. Debugging level 0 (the normal)
  65. prints messages only when something goes seriously wrong inside of MiNT itself. 
  66. Debugging level 1 prints a message when any system call fails. Debugging level
  67. 2 provides a (sickeningly) exhaustive trace of what's going on in the system.
  68.  
  69. CTRL-ALT-F5 shows what memory is being used in the system
  70. CTRL-ALT-F6 prints a list of all processes in the system
  71. CTRL-ALT-DEL provides a (warm) boot, as in TOS >= 1.4, and
  72. CTRL-ALT-SHIFT-DEL provides a cold boot.
  73.  
  74. Some other keys are recognized by MiNT if the process is doing I/O in
  75. "cooked" mode:
  76. ^C (CTRL-C): interrupt running program with signal SIGINT. This (usually)
  77.     will kill the process, unless it has made arrangements to catch it.
  78.     Note that ^C takes effect immediately under MiNT, whereas under TOS
  79.     it only takes effect when the process reads or writes.
  80. ^\: send a QUIT signal to a process; usually the same end result as ^C, but
  81.     it is guaranteed to kill a TOS program (only MiNT specific programs
  82.     know how to catch it). Use with caution.
  83. ^Z: suspend the current process
  84.  
  85. These keys do *not* have any effect on processes operating in "raw" mode,
  86. such as editors. However, you can force these to work even on such programs
  87. by holding down the ALT key as well, i.e. CTRL-ALT-Z will always suspend
  88. the process. You should use caution when doing this, since some programs
  89. will function incorrectly and/or lose data if interrupted when they
  90. aren't expecting it.
  91.  
  92.  
  93. The MiNT Configuration File
  94.  
  95. If MiNT finds a file called "mint.cnf" in the directory that it was
  96. started from, it will read some configuration information from it. This
  97. file is an ordinary ASCII text file; it can be created with any editor
  98. that will produce plain ASCII files (if you're using a fancy word
  99. processor, make sure you save the file as "plain ASCII text" or
  100. "unformatted text" or whatever).
  101.  
  102. The commands in mint.cnf are placed one per line, and may be of the following
  103. forms:
  104.  
  105. INIT=d:\foo\bar.prg
  106.     This specifies the drive and full path name to the program you
  107.     want MiNT to run at boot up time. The default is try ".\init.prg",
  108.     if that file exists, otherwise to run the GEM desktop.
  109. HARDSCROLL=25
  110.     This specifies that hardware scrolling should be used for
  111.     the u:\dev\fasttext text accelerator. This dramatically speeds
  112.     up text operations, but may interfere with GEM and graphics
  113.     programs. Put this line *before* any use of u:\dev\fasttext.
  114. CON=u:\dev\fasttext
  115.     Specifies the use of MiNT's built in text accelerator instead
  116.     of the normal BIOS console. This speeds up text output quite
  117.     a bit (more than 300%) but may not be completely compatible;
  118.     in particular, the escape codes for setting foreground/background
  119.     character colors are not supported.
  120. PRN=d:\foo\bar
  121.     Specifies a file that should be used for all printer output.
  122.     (The default is u:\dev\centr, which is the device corresponding
  123.     to the centronics port.)
  124.  
  125. cd d:\foo
  126.     Change the current drive and directory. This isn't terribly
  127.     useful, unless your initial program (see above) expects to run
  128.     with some particular directory as the current one.
  129.  
  130. exec d:\bin\prog.prg arg1 arg2 ...
  131.     Execute a program, with some arguments. The full path name and
  132.     extension (.prg, .tos, .ttp, or whatever) of the program to
  133.     execute must be given.
  134.  
  135. ren d:\nm1 d:\nm2
  136.     Rename a file or directory. This is useful mainly on the pseudo-drive
  137.     v:, which refers to devices. For example, the RS232 port on the ST
  138.     is called "v:\modem1". Earlier versions of MiNT called this
  139.     "v:\rs232", so if your programs care about this you might want
  140.     to put "ren v:\modem1 v:\rs232" to maintain compatibility.
  141.     Similarly, if your software has been ported from Unix and expects
  142.     terminals to be called "tty*", then you might want to put
  143.     "ren v:\modem1 v:\tty1" instead.
  144.  
  145. setenv FOO BAR
  146.     Set the environment variable FOO to the value BAR. NOTE: If any
  147.     setenv commands are given in mint.cnf, an entirely new environment
  148.     is constructed; this means that any environment variables set by
  149.     a program in the AUTO folder will be ignored by programs run under
  150.     MiNT. This allows you to have two default environments, one for
  151.     running under MiNT set in mint.cnf, and one for normal TOS set
  152.     by an AUTO folder program.
  153.  
  154. sln d:\foo\bar u:\baz
  155.     Create a symbolic link called "u:\baz" for the file (or directory)
  156.     d:\foo\bar. Only drive u: supports symbolic links, so the second
  157.     name *must* be on drive u:; the first name can be anything.
  158.     A symbolic link is just an alias or nickname for a file; if the
  159.     sample line is included in your mint.cnf file, then references
  160.     to u:\baz are automatically translated by the kernel so that
  161.     they "really" refer to d:\foo\bar. If d:\foo\bar is actually
  162.     a subdirectory, with the file "frob.txt" in it, then that
  163.     file can be accessed either through the name "d:\foo\bar\frob.txt"
  164.     or "u:\baz\frob.txt".
  165.  
  166.     Symbolic links are often used to tell programs where to look for
  167.     files; in this respect they're somewhat like environment variables.
  168.     Some "standard" links are:
  169.         u:\bin        directory to find programs in
  170.         u:\etc        directory to find certain general
  171.                 configuration files (e.g. passwd and termcap)
  172.         u:\local    directory to find node-specific files in
  173.                 (for networked systems)
  174.         u:\lib        directory to find C libraries in
  175.         u:\include    directory to find C header files in
  176.     You can use whatever of these are convenient, or add some others
  177.     of your own.
  178.  
  179.  
  180. Pseudo Drives
  181.  
  182. MiNT provides some fake "disk drives"; if the contents of these drives
  183. are listed, various "files" are shown. These "files" are not necessarily
  184. real files, but may represent other objects such as executing programs or
  185. regions of memory.
  186.  
  187. The most important of these pseudo drives is drive U:. This is a
  188. "unified" file system that has all other drives as subdirectories.
  189. For example, U:\A\FOO\BAR is another name for the file A:\FOO\BAR.
  190. Symbolic links can also be created from drive U: to other drives;
  191. e.g. if the line
  192.     sln U:\ETC C:\UNIX\ETC
  193. appears in mint.cnf, then the file U:\ETC\TERMCAP will be another
  194. name for the file C:\UNIX\ETC\TERMCAP, and so on.
  195.  
  196. Finally, drive U: contains some special subdirectories, as follows:
  197.  
  198. U:\PIPE contains files which are FIFO queues (e.g. pipes). All files
  199. created in this directory are temporary; when the last program using a FIFO
  200. closes it, it is erased. Normally, U:\PIPE will be empty, but it will
  201. have items on it when you're running a window manager, print spooler,
  202. or similar program that uses FIFOs or pseudo-ttys for communication.
  203.  
  204. U:\DEV contains files which correspond to the BIOS devices; this allows
  205. you to access these devices from within programs. For example, saving an
  206. ASCII text file to "U:\DEV:\PRN" should cause it to be printed on your printer.
  207. Of course, this will work *only* with ASCII data, so don't expect to get
  208. anything meaningful printed if you try to save your spreadsheet to "U\DEV\PRN"!
  209. The following devices are available:
  210.    CENTR: the centronics printer port
  211.    MODEM1: the RS232 serial port
  212.    MIDI: midi port
  213.    KBD: intelligent keyboard controller
  214.    PRN: printer device (not necessarily the real printer if redirected)
  215.    AUX: auxiliary terminal (usually, but not always, the rs232 port)
  216.    CON: current control terminal (NOT necessarily the keyboard/screen!)
  217.    TTY: same as above
  218.    STDIN: current file handle 0 (standard input)
  219.    STDOUT: current file handle 1 (standard output)
  220.    STDERR: current file handle 2 (standard error)
  221.    CONSOLE: (physical console) the keyboard/screen
  222.    FASTTEXT: an alternate, faster text device for the console screen
  223.    MOUSE: a Sun compatible mouse device. Don't use this directly;
  224.           use the AES/VDI functions instead.
  225.    NULL: a null device (like Unix's /dev/null)
  226.  
  227. The "STD*" file handles are useful for providing I/O redirection to programs
  228. that normally require file names on the command line; for example, if you
  229. want to run such a program in a pipeline.
  230.  
  231. U:\PROC has special files that represent all currently executing
  232. processes, such as whether they're running, ready, or waiting, their process
  233. i.d. numbers, and the amount of memory they've taken. Deleting one of the
  234. "files" kills the corresponding process. (Killing MiNT is impossible;
  235. killing GEM is a very bad idea). The "files" will have names like "INIT.001";
  236. this means that the process name is "INIT" (presumably because it was started
  237. from a file like "INIT.PRG"), and its process i.d. is 1. You can rename
  238. processes just as if they were files, except that any extension you give is
  239. always replaced with the process i.d. (e.g. if you rename INIT.001 to FOO.BAR,
  240. it will really become FOO.001). The size of a process is the amount of memory
  241. that is allocated to it. Its date/time stamp indicates when it started
  242. executing. A process' current state is reflected by its attribute bits; most
  243. of these are not visible from the desktop, alas, but here are the combinations
  244. and their meanings:
  245.     attribute      process state
  246.       0x00        currently running
  247.       0x01        ready to run
  248.       0x20        waiting for an event (e.g. for a child to finish)
  249.       0x21        waiting for I/O
  250.       0x22        zombie (exited, but parent doesn't know yet)
  251.       0x02        terminated and resident
  252.       0x24        stopped by a signal
  253. Deleting a "file" in U:\PROC will send a SIGTERM signal to the corresponding
  254. process, which will usually result in that process being terminated. It
  255. is not possible to delete processes which are terminated and resident,
  256. or zombie processes.
  257.  
  258. U:\SHM is a place for shared memory. A program may create a file in U:\SHM
  259. and attach a block of memory to it. Thereafter, other programs may open
  260. that file and use the memory. This provides a fast way to transfer large
  261. amounts of data between processes.
  262.  
  263. Other pseudo drives that are available are Q:, V:, and X:. These are just
  264. aliases for U:\PIPE, U:\DEV, and U:\PROC, respectively, and exist for
  265. backwards compatibility. Don't use them in new applications; they will
  266. go away soon.
  267.  
  268. Note that the TOS 1.0 desktop won't recognize drives above P. Other versions
  269. of TOS will, though, so you can use the Install Drive menu selection to
  270. install the pseudo drives so that the desktop can recognize them.
  271.  
  272.  
  273. File Handles and Devices
  274.  
  275. File handle -1 refers to the current control terminal, NOT necessarily
  276. the console (this is where it points by default). BIOS handle 2 also
  277. refers to the control terminal, so that e.g. Bconout(2, c) outputs
  278. a character to the control terminal. Thus,
  279.     Fforce(-1, Fopen("U:\DEV\MODEM1", 3));
  280.     r = Bconin(2);
  281. reads a character from the RS232 port under MiNT. This is done so that
  282. programs that use the BIOS for I/O will be able to run in windows or
  283. over the modem. Similarly, the DOS device CON: refers to the current
  284. control terminal, so Fopen("CON:", 3) is normally equivalent to Fdup(-1).
  285. To access the physical console, use device U:\DEV\CONSOLE.
  286.  
  287. In a similar fashion, file handle -2 and bios device 1 (DOS device AUX:)
  288. may be redirected away from the RS232 port (device U:\DEV\MODEM1), and
  289. file handle -3 and bios device 0 (DOS device PRN:) may be directed away
  290. from the Centronics printer port (device U:\DEV\CENTR). Since both the DOS
  291. handles and BIOS device numbers are redirected, any program at all will
  292. obey the redirection unless it accesses the hardware directly (or unless
  293. it was written for MiNT and specifically uses the new device names
  294. like U:\DEV\CENTR; this should be done only if *absolutely* necessary!).
  295. See also the PRN= and CON= commands for mint.cnf, which provide another
  296. way to redirect the printer and console (actually, it's just another
  297. interface to the same method of redirection).
  298.  
  299. File handles -4 and -5 are new with MiNT, and refer to the MIDI input
  300. and output devices respectively. Redirecting these handles will affect
  301. BIOS operations on bios device 4 (the MIDI port).
  302.  
  303.  
  304. Background Processes
  305.  
  306. (Note that the programs bg.ttp and pipe.ttp, along with some other
  307. sample MiNT utilities, are found in a separate file called
  308. "mntutl.zoo").
  309.  
  310. Programs may be started in the background. A sample program ("bg.ttp")
  311. is provided that will do this for you. It works best from a shell;
  312. for example, to make foo.ttp in the background from gulam, type:
  313.     cd \foo\src
  314.     bg.ttp -o make.out make foo.ttp
  315. The "-o make.out" tells "bg" to redirect the command's standard tty,
  316. output, and error output (handles -1, 1, and 2) to "make.out".
  317. You might also want to redirect the standard input from an empty
  318. file, or from a file that will never have input waiting (like V:\NUL)
  319. so that "make" won't try to read anything from your console.
  320.  
  321. Shells designed to work with MiNT (for example, the "mintshel.ttp" that is
  322. provided with the MiNT utilities) may use the Unix "&" notation for running
  323. processes in the background; with this notation, the job above would be:
  324.     cd \foo\src
  325.     make foo.ttp >make.out &
  326. (here the ">make.out" is the notation for redirecting the standard output
  327. of a process). Note that the sample shell does not provide a way of
  328. redirecting the standard error output; however, it does provide job
  329. control, and processes that try to write on the terminal
  330. will be stopped automatically. See "Job Control" below.
  331.  
  332.  
  333. Pipes
  334.  
  335. Pipes are special files that are used to communicate between processes. The
  336. data in a pipe is always in memory, so using a pipe instead of a temporary
  337. file is usually faster; it also doesn't consume disk space. Only 2048 bytes
  338. can be held in a pipe at once; when a process tries to write more data,
  339. it is suspended until another process reads some data, thus "emptying"
  340. the pipe. If there are no more readers, a process writing on a pipe is
  341. terminated.
  342.  
  343. A simple "pipe" program is provided to run two programs concurrently,
  344. passing data between them in a pipe. The syntax is
  345.     pipe.ttp cmd1 cmd2
  346. which is equivalent to the Unix "cmd1 | cmd2". Note that if cmd1 or cmd2
  347. contain arguments, then you must run the "pipe" program from a shell that
  348. supports the Atari standard extended argument convention, and that you
  349. must enclose the commands in quotes, e.g. in gulam:
  350.     set env_style mw    # extended arguments
  351.     pipe 'ls.ttp -l foo' 'fgrep.ttp myfile'
  352. does the same as the Unix command
  353.     ls -l foo | fgrep myfile
  354. or using a temporary file
  355.     ls -l foo >junk; fgrep myfile <junk; rm junk
  356.  
  357. Shells designed to work explicitly with MiNT will probably not need the
  358. external "pipe" command, and instead will use the Unix notation for
  359. pipelines. This second method is preferable, as it provides a way of
  360. joining more than two programs in a pipeline.
  361.  
  362.  
  363. Job Control
  364.  
  365. MiNT supports a terminal access protocol for job control. The ^Z
  366. (control-Z) key can be used to suspend a process. The process can
  367. be restarted again if it is sent the appropriate signal. There is
  368. also a "delayed" suspend key, ^Y, that takes effect only when
  369. a process attempts to read it.
  370.  
  371. Some programs written for TOS put the terminal in "raw" mode, where no
  372. control characters are interpreted. You can use CTRL-ALT-Z to achieve
  373. the effect of ^Z for such programs. However, this feature should be used
  374. with caution -- it's possible that the TOS program had a good reason
  375. for not wanting to be interrupted!
  376.  
  377. Once a program has been suspended, it must be restarted again. MiNT
  378. aware shells (e.g. mintshel.ttp) usually provide some sort of
  379. "fg" command that restarts the suspended process and brings it to
  380. the foreground. This suspend-restart cycle may be performed any
  381. number of times.
  382.  
  383. If the terminal mode "tostop" is set (this is the default), then any
  384. background program that tries to write to the console will be suspended
  385. automatically; it must then be brought to the foreground with the
  386. "fg" command before the write continues. This behavior may be changed
  387. with the "stty" utility; after an "stty -tostop" command is issued,
  388. background programs will no longer be suspended when they write to the
  389. terminal.
  390.  
  391. Background programs that try to read input from the console will also
  392. be automatically suspended until brought into the foreground. This
  393. happens regardless of the setting of the "tostop" flag.
  394.  
  395.  
  396. Programming with MiNT
  397.  
  398. A file (mintbind.h) is provided that gives a C interface to the new
  399. MiNT system calls. Users of other programming languages will have to write
  400. the interfaces themselves; it should be relatively straightforward, as long
  401. as your compiler provides a way to call GEMDOS directly.
  402.  
  403. Testing for the presence of MiNT:
  404.  
  405. There are several ways to check to see if MiNT is active. The best
  406. way is to check the cookie jar; MiNT installs a cookie of
  407. 0x4d694e54 (in ASCII, 'MiNT'), with a value consisting of the major/
  408. minor version numbers in the high/low bytes of the low word. Thus, MiNT
  409. version 1.2 will have a cookie value of 0x00000102L. (This isn't
  410. the place to explain the cookie jar, but basically it's a list of
  411. (cookie, value) pairs of longwords, terminated by cookie 0; a pointer
  412. to the jar is found at 0x5a0. MiNT always installs a cookie jar; versions
  413. of TOS prior to 1.6 don't always, in which case 0x5a0 will contain 0).
  414.  
  415. A "quick and dirty" way to see if MiNT is active is to make a system
  416. call that only exists under MiNT (preferably one with no side effects!).
  417. Pgetpid() or Syield() are good choices. If MiNT is not active, these
  418. calls will fail, returning -32 (invalid function). This method has the
  419. disadvantage that future versions of TOS, or other multitasking programs,
  420. may use the same trap numbers as MiNT, but have different meanings.
  421. For this reason, the "cookie jar" method is preferred.
  422.  
  423. Interprocess Communication:
  424.  
  425. MiNT provides 5 forms of interprocess communication (IPC): signals, fifos,
  426. shared memory, message passing, and semaphores.
  427.  
  428. Signals:
  429.  
  430. Signals are a way of notifying a process of an event. The Pkill(pid, sig)
  431. system call is used to send signal number "sig" to the process with process
  432. id "pid". It is called "Pkill" because the default action of most signals is
  433. to terminate the process. If a process wishes to catch a signal and do
  434. processing, it can use the Psignal(sig, func) system call to arrange to have
  435. function "func" called when signal "sig" is received. If func is 0, then
  436. the default action is restored. If func is 1, then the signal will be ignored.
  437.  
  438. Processes can temporarily block receipt of signals via the Psigblock() and
  439. Psigsetmask() system calls.
  440.  
  441. See the file "signal.doc" for a more complete explanation of signals.
  442.  
  443. Fifos:
  444.  
  445. Fifos are "first in first out" message queues. Pipes are a special kind of
  446. (unidirectional) fifo. Fifos are represented by files in the subdirectory
  447. "PIPE" on drive "U:". They are created with the Fcreate(name, flags)
  448. system call. "name" will be the name under which the fifo is known
  449. (maximum 13 characters); "flags" is explained below. The returned file handle
  450. is treated just like an ordinary file, and may be written to and read from
  451. (unless the fifo is unidirectional, in which case it may only be written to).
  452. The program that creates the fifo is normally called the "server". Other
  453. programs ("clients") may use the Fopen(name, mode) system call to open the
  454. other end of the fifo and read the data that the server writes, or write data
  455. for the server to read. When the last program (either client or server) using
  456. a fifo closes it, the fifo is deleted automatically. Note that one program can
  457. be both client and server, if it creates a fifo with Fcreate and then opens it
  458. again with Fopen. Also, children of the server can inherit the Fcreate'd file
  459. handle and thus have access to the "server" side of the fifo.
  460.  
  461. The bits in the "flags" argument to Fcreate have the following meanings:
  462. 0x01: make fifo unidirectional (server can write, clients can read)
  463. 0x02: cause reads to return EOF if no other processes are writing, and writes
  464.       to raise the SIGPIPE signal if no other processes are reading. The
  465.       default action (if this flag is not given) is to block waiting for
  466.       reads and writes
  467. 0x04: make the fifo a pseudo-tty; to client processes, the fifo will act
  468.       just like a terminal with the server "typing" the characters; for
  469.       example, if the server writes a ^C, SIGINT will be sent to clients
  470.  
  471. Attempting to Fcreate() a fifo with the same name as an already existing
  472. one will result in an access error (i.e. the Fcreate will fail).
  473.  
  474. Pipes may be created through the Fpipe() system call as well as through
  475. the Fcreate/Fopen pair; the former method is easier, since the kernel
  476. takes care of name conflicts, etc.
  477.  
  478. Fifos may be locked by processes via the Fcntl system call, as follows:
  479.  
  480. struct flock {
  481.     short l_type;        /* type of lock */
  482. #define F_RDLCK        0
  483. #define F_WRLCK        1
  484. #define F_UNLCK        3
  485.     short l_whence;        /* what is the lock relative to? */
  486.         /* 0 == start of file, 1 == current pos. in file, 2 == EOF */
  487.     long l_start;        /* start of locked region */
  488.     long l_len;        /* 0 for rest of file */
  489.     short l_pid;        /* set by F_GETLK */
  490. };
  491.  
  492. Fcntl(fd, &lock, F_SETLK): set a lock as specified by the lock structure.
  493. The current version of MiNT only understands locks on the whole FIFO,
  494. so lock.l_start and lock.l_len should both be 0. If lock.l_type is F_UNLCK,
  495. then the lock is released. Otherwise, the file whole file is locked
  496. (future versions of MiNT may distinguish between read and write locks,
  497. but for now all locks are treated as write locks (F_WRLCK) and block both
  498. reads and writes). If another process has locked the fifo, returns -36
  499. (access denied). If a process holding a lock terminates, the fifo is
  500. automatically unlocked.
  501.  
  502. Fcntl(fd, &lock, F_GETLK): if a lock exists on the fifo, set lock to
  503. indicate what kind of lock it is; otherwise, set lock.l_type to F_UNLCK.
  504.  
  505. Locks are only "advisory"; that is, programs may ignore locks if they
  506. choose to do so. However, they are a good way to insure that two clients'
  507. data are not mixed together in a fifo.
  508.  
  509. NOTE: file locking will eventually be implemented for all files, but
  510. for now only fifos support file locking.
  511.  
  512. See the sample LPR and LPD utilites for a demonstration of how to use fifos.
  513.  
  514. Shared memory:
  515.  
  516. Children created with the Pexec(4,...) or with Pexec(104,...) share all of
  517. their parent's memory, as do children created with the Pvfork() system call.
  518. Hence, they may communicate with their parent (or with each other) via
  519. global variables.
  520.  
  521. A more general shared memory mechanism is provided by U:\SHM. Files in
  522. that directory represent blocks of memory. A program may offer to share
  523. its memory by creating a file in U:\SHM and executing an Fcntl call
  524. (SHMSETBLK) to associate a block of memory with the file. Other programs
  525. may then open the file and do a SHMGETBLK call to gain access to that
  526. memory.
  527.  
  528. Rendezvous:
  529.  
  530. The Pmsg() system call provides a simple message based form of IPC. See
  531. the manual page for Pmsg for further details. The use of FIFOs is generally
  532. to be preferred to Pmsg(), since they are more flexible.
  533.  
  534. Semaphores:
  535.  
  536. Semaphores may be created and otherwise accessed via the Psemaphore
  537. system call. See the manual page for Psemaphore for more details.
  538.  
  539.  
  540. MiNT extensions to GEMDOS calls:
  541.  
  542. Fsfirst/Fsnext:
  543.     MiNT domain processes (see the Pdomain()) system call below) get
  544. lower case filenames from Fsfirst/Fsnext on a TOS filesystem. This is
  545. because most programs end up converting them to lowercase anyways, to
  546. be more Unix-like. *Please* don't do this translation yourself, let
  547. MiNT handle it -- some filesystems (e.g. the minix one) are case
  548. sensitive! If you really, truly, prefer uppercase filenames, run in
  549. the TOS domain.
  550.  
  551. Pexec(100, name, cmdline, environment):
  552.     Similar to Pexec(0, ...), except the calling program does not wait for
  553. the child to finish. Returns a negative error code, or the (positive)
  554. process I.D. of the child.
  555.  
  556. Pexec(104, name, basepage, 0L):
  557.     Similar to Pexec(4, ...); starts executing a basepage previously
  558. set up by Pexec mode 3, 5, or 7. The caller does not wait for
  559. the child to finish. Returns a negative error code, or the process I.D.
  560. of the child. Note that the child's environment and basepage are
  561. owned by both the child and the parent (indeed, the child shares all
  562. memory owned by the parent). "name" is a pointer to a string
  563. to be used to supply a name for the new process; if it is NULL, then
  564. the parent's name is used.
  565.  
  566. Pexec(106, name, basepage, 0L):
  567.     Similar to Pexec(104,...) except that the child's environment and
  568. basepage are *not* owned by the parent; nor does the child share
  569. any memory allocated to the parent.
  570.  
  571. Pexec(200, name, cmdline, environment):
  572.     As with Pexec(0,...) and Pexec(100,...) this runs a program. However,
  573. with this variant the caller is completely replaced with the executing
  574. program. The process retains its process i.d. and most other attributes,
  575. but all of its memory is freed and a new address space is set up for it
  576. containing the code from the indicated program. Whereas Pexec(0,...)
  577. is like a subroutine call, Pexec(200,...) is like a "goto". It returns
  578. only if an error occurs that makes it impossible to run the indicated
  579. program (e.g. if not enough memory is available, or the file is not
  580. found).
  581.  
  582.  
  583. New MiNT calls:
  584.  
  585. See the manual pages in the man/ subdirectory for descriptions of
  586. these calls.
  587.  
  588. void Syield():                    [ GEMDOS 0xff ]
  589. word Fpipe( word *ptr ):            [ GEMDOS 0x100 ]
  590. long Fcntl( word f, long arg, word cmd):    [ GEMDOS 0x104 ]
  591. long Finstat( word f ):                [ GEMDOS 0x105 ]
  592. long Foutstat( word f )                [ GEMDOS 0x106 ]
  593. long Fgetchar(word f, word mode):        [ GEMDOS 0x107 ]
  594. long Fputchar( word f, long c, word mode ):    [ GEMDOS 0x108 ]
  595. long Pwait():                    [ GEMDOS 0x109 ]
  596. word Pnice( word delta ):            [ GEMDOS 0x10a ]
  597. word Pgetpid():                    [ GEMDOS 0x10b ]
  598. word Pgetppid():                [ GEMDOS 0x10c ]
  599. word Pgetpgrp():                [ GEMDOS 0x10d ]
  600. word Psetpgrp(pid, newgrp):            [ GEMDOS 0x10e ]
  601. word Pgetuid():                    [ GEMDOS 0x10f ]
  602. word Psetuid( word id ):            [ GEMDOS 0x110 ]
  603. word Pkill( word pid, word sig ):        [ GEMDOS 0x111 ]
  604. long Psignal(word sig, long handler):        [ GEMDOS 0x112 ]
  605. word Pvfork():                    [ GEMDOS 0x113 ]
  606. word Pgetgid():                    [ GEMDOS 0x114 ]
  607. word Psetgid(word id):                [ GEMDOS 0x115 ]
  608. long Psigblock(long mask):            [ GEMDOS 0x116 ]
  609. long Psigsetmask(long mask):            [ GEMDOS 0x117 ]
  610. long Pusrval(long arg):                [ GEMDOS 0x118 ]
  611. word Pdomain(word newdom):            [ GEMDOS 0x119 ]
  612. void Psigreturn():                [ GEMDOS 0x11a ]
  613. word Pfork():                    [ GEMDOS 0x11b ]
  614. long Pwait3(word flag, long *rusage):        [ GEMDOS 0x11c ]
  615. word Fselect(word timeout, long *rfds, long *wfds, long *xfds):
  616.                         [ GEMDOS 0x11d ]
  617. void Prusage( long r[8] ):            [ GEMDOS 0x11e ]
  618. long Psetlimit(word lim, long value):        [ GEMDOS 0x11f ]
  619. long Talarm( long secs ):            [ GEMDOS 0x120 ]
  620. void Pause():                    [ GEMDOS 0x121 ]
  621. long Sysconf( word n ):                [ GEMDOS 0x122 ]
  622. long Psigpending()                [ GEMDOS 0x123 ]
  623. long Dpathconf( char *name, word n ):        [ GEMDOS 0x124 ]
  624. long Pmsg( word mode, long mbox, void *msg ):    [ GEMDOS 0x125 ]
  625. long Fmidipipe( word pid, word in, word out ):    [ GEMDOS 0x126 ]
  626. word Prenice( word pid, word delta ):        [ GEMDOS 0x127 ]
  627. long Dopendir( char *name, word flag ):        [ GEMDOS 0x128 ]
  628. long Dreaddir( word buflen, long dir, char *buf):[GEMDOS 0x129 ]
  629. long Drewinddir( long dir ):            [ GEMDOS 0x12a ]
  630. long Dclosedir( long dir ):            [ GEMDOS 0x12b ]
  631. long Fxattr( word flag, char *name, void *buf ):[ GEMDOS 0x12c ]
  632. long Flink( char *oldname, char *newname ):    [ GEMDOS 0x12d ]
  633. long Fsymlink( char *oldname, char *newname ):    [ GEMDOS 0x12e ]
  634. long Freadlink( word siz, char *buf, char *name):[GEMDOS 0x12f ]
  635. long Dcntl( word cmd, char *name, long arg ):    [ GEMDOS 0x130 ]
  636. long Fchown( char *name, word uid, word gid):    [ GEMDOS 0x131 ]
  637. long Fchmod( char *name, word mode ):        [ GEMDOS 0x132 ]
  638. word Pumask( word mask ):            [ GEMDOS 0x133 ]
  639. long Psemaphore(word mode, long id, long timeout): [ GEMDOS 0x134 ]
  640. word Dlock( word mode, word drive ):        [ GEMDOS 0x135 ]
  641. void Psigpause( long sigmask ):            [ GEMDOS 0x136 ]
  642. long Psigaction( word sig, long act, long oact):[ GEMDOS 0x137 ]
  643. long Pgeteuid():                [ GEMDOS 0x138 ]
  644. long Pgetegid():                [ GEMDOS 0x139 ]
  645.